package com.hippo.core.core.network.interceptor

import android.os.Build
import com.hippo.core.config.AppStoreKey
import com.hippo.core.core.manager.AppStore
import okhttp3.Interceptor
import okhttp3.Response

/**
 * @author stone
 */
class HeaderInterceptor : Interceptor  {

    val brand = "${Build.MANUFACTURER} : ${Build.MODEL}"


    override fun intercept(chain: Interceptor.Chain): Response {
        val original = chain.request()
        val request = original.newBuilder().apply {

            header("terminal", "1")
            header("language", AppStore.readString(AppStoreKey.languageCode,"0").orEmpty())
            header("device", brand)
            header("userToken", AppStore.readString(AppStoreKey.userToken).orEmpty())

        }.build()
        return chain.proceed(request)
    }
}